package com.itheima.app.controller;

import com.itheima.app.manager.MakeFriendManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class MakeFriendController {

    @Autowired
    private MakeFriendManager makeFriendManager;

    @GetMapping("/tanhua/todayBest")//查询今日佳人
    public ResponseEntity findTodayBest() {
        return makeFriendManager.findTodayBest();
    }

    @GetMapping("/tanhua/recommendation")//查询推荐列表
    public ResponseEntity findRecommendation(@RequestParam(value = "page", defaultValue = "1") Integer pageNum,
                                             @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {
        return makeFriendManager.findRecommendation(pageNum, pageSize);
    }

    @GetMapping("/tanhua/{recommendUserId}/personalInfo")// 推荐用户详情
    public ResponseEntity findPersonalInfo(@PathVariable Long recommendUserId) {
        return makeFriendManager.findPersonalInfo(recommendUserId);
    }

    @GetMapping("/tanhua/strangerQuestions")//（聊一下）查看陌生人问题
    public ResponseEntity findStrangerQuestions(@RequestParam("userId") Long jiaRenId){
      return makeFriendManager.findStrangerQuestions(jiaRenId);
    }

    @GetMapping("/movements/visitors")//查询最近访客
    public ResponseEntity findVisitors(){
        return makeFriendManager.findVisitors();
    }

    @PostMapping("/baidu/location")//上传地理位置
    public void uploadLocation(@RequestBody Map<String,String> map){
        double latitude = Double.parseDouble(map.get("latitude"));
        double longitude = Double.parseDouble(map.get("longitude"));
        String addrStr = map.get("addrStr");
        makeFriendManager.uploadLocation(latitude,longitude,addrStr);
    }
    @GetMapping("/tanhua/search")//查询附件的人
    public ResponseEntity findSearch(String gender,String distance){
        return makeFriendManager.findSearch(gender,distance);
    }
    @GetMapping("/tanhua/cards")//探花卡片
    public ResponseEntity findCards(){
        return makeFriendManager.findCards();
    }
}
